package com.bwie.product.controller;

import com.bwie.common.core.domain.Result;
import com.bwie.common.core.utils.StringUtils;
import com.bwie.product.domain.vo.SearchParam;
import com.bwie.product.domain.vo.SearchResult;
import com.bwie.product.service.ProductSearchService;
import com.bwie.product.service.ProductService;
import org.apache.lucene.util.QueryBuilder;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
import org.elasticsearch.search.rescore.QueryRescorer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.sql.Array;
import java.util.ArrayList;
import java.util.List;

@RequestMapping("/productSearch")
@RestController

public class ProductSearchController {
    @Autowired
    private ProductSearchService productSearchService;

    /**
     * 商品搜索
     */
    @PostMapping ("/productSearch")
    public Result productSearch(@RequestBody SearchParam searchParam) throws IOException {
        SearchResult searchResult = productSearchService.productSearch(searchParam);
        return Result.success(searchResult);
    }



}
